<template>
  <div class="container">
    <van-tabs swipeable animated v-model="currentIndex">
      <!-- 默认插槽 =》 van-tab标识页签名+页签内容 -->
      <van-tab :key="item.id" v-for="item in list" :title="item.name">
        <!-- 可滚动内容区域=》默认插槽 -->
        <article-list :channelId="item.id" />
      </van-tab>
    </van-tabs>
    <span class="bar_btn" @click="isShow = true">
      <van-icon name="wap-nav"></van-icon>
    </span>
    <!-- <button @click="logintest">登录</button> -->
    <channel
      v-model="isShow"
      :channelList="list"
      :currentIndex.sync="currentIndex"
    ></channel>
  </div>
</template>

<script>
import Channel from './components/channel.vue'
// import request from '../../utils/request'
import ArticleList from './components/article.vue'
import { getUserChannelListApi } from '@/api/channel'
export default {
  components: {
    ArticleList,
    Channel
  },
  data () {
    return {
      list: [],
      isShow: false,
      currentIndex: 0
    }
  },
  created () {
    this.getChannels()
  },
  methods: {
    async getChannels () {
      const { data } = await getUserChannelListApi()
      this.list = data.channels
    }

  }
}
</script>

<style scoped lang='less'>
// 覆盖有赞页签组件的默认样式
.van-tabs {
  height: 100%;
  display: flex;
  flex-direction: column;
  // 自定义tab样式=》/deep/覆盖子组件的样式
  /deep/ .van-tabs__wrap {
    height: 36px;
    padding-right: 36px;
    .van-tab {
      line-height: 36px;
    }
    .van-tabs__line {
      background-color: #fc6627;
      height: 2px;
    }
  }
  /deep/ .van-tabs__content {
    flex: 1;
    overflow: hidden;
  }
  /deep/ .van-tab__pane {
    height: 100%;
    // 控制列表区域可滚动
    .scroll-wrapper {
      height: 100%;
      overflow-y: auto;
    }
  }
}
.bar_btn {
  width: 36px;
  height: 35px;
  position: absolute;
  top: 0;
  right: 0;
  font-size: 20px;
  text-align: center;
  line-height: 40px;
  box-shadow: -6px -6px 8px #ddd;
}
</style>
